#include "../../../odb/chat_session_member.hxx"
#include "chat_session_member-odb.hxx"
#include "../../../common/data_mysql.hpp"
#include "gflags/gflags.h"

DEFINE_bool(run_mode, false, "程序的运行模式，false-调试； true-发布；");
DEFINE_string(log_file, "", "发布模式下，用于指定日志的输出文件");
DEFINE_int32(log_level, 0, "发布模式下，用于指定日志输出等级");

void append_test(zjx_im::ChatSessionMemberTable &tb)
{
    zjx_im::ChatSessionMember csm("会话ID1", "用户ID1");
    tb.append(csm);
    zjx_im::ChatSessionMember csm1("会话ID2", "用户ID2");
    tb.append(csm1);
    zjx_im::ChatSessionMember csm2("会话ID3", "用户ID3");
    tb.append(csm2);
}

void multi_append_test(zjx_im::ChatSessionMemberTable &tb)
{
    zjx_im::ChatSessionMember csm1("会话ID3", "用户ID1");
    zjx_im::ChatSessionMember csm2("会话ID3", "用户ID2");
    zjx_im::ChatSessionMember csm3("会话ID3", "用户ID3");
    std::vector<zjx_im::ChatSessionMember> list = {csm1, csm2, csm3};
    tb.append(list);
}

void remove_test(zjx_im::ChatSessionMemberTable &tb)
{
    zjx_im::ChatSessionMember csm("会话ID3", "用户ID3");
    tb.remove(csm);
}

void ss_members_test(zjx_im::ChatSessionMemberTable &tb)
{
    auto res = tb.members("会话ID3");
    for(auto &id : res)
    {
        std::cout << id << std::endl;
    }
}

int main(int argc, char* argv[])
{
    google::ParseCommandLineFlags(&argc, &argv, true);
    zjx_im::init_logger(FLAGS_run_mode, FLAGS_log_file, FLAGS_log_level);
    auto db = zjx_im::ODBFactory::create("root", "caocao123", "127.0.0.1", "zjx_im", "utf8", 0, 1);
    
    zjx_im::ChatSessionMemberTable csmt(db);
    
    //append_test(csmt);
    //multi_append_test(csmt);
    //remove_test(csmt);
    //ss_members_test(csmt);
    // std::string str = "会话ID3";
    // csmt.remove(str);
    return 0;
}